<?php

namespace app\common\models;

class CoinOrder extends BaseModel
{
    // 未付款
    const notPay = 0;
    // 已付款
    const isPay = 1;

    // 获取用户累计充值金额
    public function topUpTotal($rule, $user_id)
    {
        // 获取用户活动期间累计充值金额
        $order_where['user_id'] = $user_id;
        if (!empty($beg_time) && !empty($end_time)){
            $order_where['order_time'] = ['between', [$rule['beg_time'], $rule['end_time']]];
        }
        if (!empty($beg_time) && empty($end_time)){
            $order_where['order_time'] = ['egt', $rule['beg_time']];
        }
        if (empty($beg_time) && !empty($end_time)){
            $order_where['order_time'] = ['elt', $rule['beg_time']];
        }
        $order_where['status'] = 1;
        $coin_order = new CoinOrder();
        $money = $coin_order->getSum($order_where, 'money');
        return sprintf('%.2f', $money);
    }

}